
//
//
var express = require('express');
var routes  = require('./routes');
var morgan  = require('morgan');

// var cookieParser = require('cookie-parser');
// var bodyParser   = require('body-parser');
// var csrf         = require('csurf');

// var csrfProtection = csrf({ cookie: true });
// var parseForm = bodyParser.urlencoded({ extended: false });

var app = express();

var server = require('http').Server(app);
var io = require('socket.io')(server);
require('./controller/home/socket')(io);

//
app.set('views', 'views');
app.set('view engine', 'html');
app.engine('html', require('ejs').renderFile);
//
app.use(express.static('public'));
app.use(morgan('dev'));
// app.use(bodyParser.urlencoded({ extended: false }))
// app.use(cookieParser());
// app.use(csrf({ cookie: true }));

// app.use((req, res, next) => {
// 	// console.log(req.csrfToken());
// 	res.locals.csrfToken = req.csrfToken();
//   next();
// });

// 生产环境使用，安全性考虑
// app.disable('x-powered-by');


//
routes(app);
server.listen(8310);
















//
